<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="ftm"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.css" />
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/addBook.css" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/js/ajaxfileupload.js"></script>
</head>

<script type="text/javascript">
	function fileChange(){//注意：此处不能使用jQuery中的change事件，因此仅触发一次，因此使用标签的：onchange属性
		$.ajaxFileUpload({
			url: "${pageContext.request.contextPath}/member/ajaxImg",//用于文件上传的服务器端请求地址
			secureuri: false,//一般设置为false
			fileElementId: 'pimage',//文件上传控件的id属性  <input type="file" id="pimage" name="pimage" />
			dataType: 'json',//返回值类型 一般设置为json
			success: function(obj) //服务器成功响应处理函数
			{
				$("#imgDiv").empty();  //清空原有数据
				//创建img 标签对象
				var imgObj = $("<img>");
				//给img标签对象追加属性
				imgObj.attr("src","${pageContext.request.contextPath}/image_big/"+obj.imgurl);//设置图片存放位置
				imgObj.attr("width","100px");
				imgObj.attr("height","100px");
				//将图片img标签追加到imgDiv末尾
				$("#imgDiv").append(imgObj);
				//将图片的名称（从服务端返回的JSON中取得）赋值给文件本框
				//$("#imgName").html(data.imgName);
			},
			error: function (e)//服务器响应失败处理函数
			{
				alert(e.message);
			}
		});
	}
</script>


<body>
<div id="addAll">
	<div id="nav">
		<p>商品管理>更新商品</p>
	</div>

	<script type="text/javascript">
		function myclose(ispage) {
			window.location="${pageContext.request.contextPath}/admin/product?flag=split&ispage="+ispage;
			//window.close();
		}
	</script >
	<script type="text/javascript">
	function g() {
		var i = document.getElementsByTagName("select")
		var j = i.selectedIndex;
		var k = i.option[j].value
		alert(j);
		conconsole.log(k);


	}





	</script>
	<div id="table">
		<form action="${pageContext.request.contextPath}/member/update"  method="post" >
			<input type="hidden" value="${memberinfo.id}" name="id">
			<input type="hidden" value="${memberinfo.state}" name="state">
			<input type="hidden" value="${page}" name="page">
			<table>
				<tr>
					<td class="one">姓名</td>
					<td><input type="text" name="name" class="two" value="${memberinfo.name}"></td>
				</tr>

				<tr>
					<td class="one">password</td>
					<td><input type="password" name="password" class="two" value="${memberinfo.password}"></td>
				</tr>

				<tr>
					<td class="one">性别</td>
					<td><input type="text" name="sex" class="two" value="${memberinfo.sex}"></td>
				</tr>


				<tr>
					<td class="one">图片介绍</td>
					<td> <br><div id="imgDiv" style="display:block; width: 40px; height: 50px;"><img src="/image_big/${memberinfo.photo}" width="100px" height="100px" ></div><br><br><br><br>
						<input type="file" id="pimage" name="pimage" onchange="fileChange()">
						<span id="imgName"></span><br>

					</td>
				</tr>
				<tr class="three">
					<td class="four"></td>
					<td><span></span></td>
				</tr>

				<tr>
					<td class="one">phone</td>
					<td><input type="number" name="phone" class="two"  value="${memberinfo.phone}"></td>
				</tr>


				<tr>
					<td class="one">地址</td>
					<td>
						<input type="text" name="address" class="two" value="${memberinfo.address}">
					</td>
				</tr>

				<tr>
					<td class="one" >创建时间</td>
					<td>
						<fmt:formatDate value="${memberinfo.createtime}" pattern="yyyy-MM-dd"/>
					</td>
				</tr>
				<tr>
					<td class="one">会员等级</td>
					<td>
						<select  name="gradeId" class="two" >
							<option value="${memberinfo.grade.id}" selected="selected">${memberinfo.grade.grade}</option>
							<span>   <c:forEach items="${grade}" var="pt" >

								<option <c:if test="${memberinfo.grade.id==pt.id}">  hidden   </c:if>value="${pt.id}" >${pt.grade}</option>
							</c:forEach></span>

						</select>
					</td>
				</tr>
				<tr>
					<td class="one">价格</td>
					<td>
						<input type="text" name="price" class="two" value="${memberinfo.price}">
					</td>
				</tr>

				<tr>
					<td>
						<input type="submit" onclick="g()" value="提交" class="btn btn-success">
					</td>
					<td>
						<input type="reset" value="取消" class="btn btn-default" onclick="myclose(1)">
					</td>
				</tr>
			</table>
		</form>

	</div>
</div>

</body>

</html>